﻿/**
 * Topic.java 1.0 2007-4-15 上午12:19:36,创建 by yangfan
 */


package org.in4j.bbs.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 *
 * @author 杨帆
 * @version 1.0 2007-4-15 上午12:19:36,创建
 */
public class Topic
{
	/**0-普通主题*/
	public static final int TYPE_TOPIC = 0;
	/**1-投票类主题*/
	public static final int TYPE_VOTE = 1;

	/**0-正常状态的帖子*/
	public static final int STATUS_COMMON = 0;
	/**1-锁定(不能回复,不能修改)*/
	public static final int STATUS_LOCKED = 1;
	/**2-置顶*/
	public static final int STATUS_PINENED = 2;
	/**3-总置顶*/
	public static final int STATUS_GLOBAL_PINENED = 3;
	/**4-删除*/
	public static final int STATUS_DELETED = 4;

	private Integer id;
	private String title;
	private String subtitle;
	private String content;
	private Timestamp publishTime;
	private int replyCount;
	private int viewCount;
	private String updateUser;
	private Timestamp updateTime;
	private int status;
	private int type;

	private User author;
	private Board board;
	private Set<Post> replies = new HashSet<Post>();

	public Set<Post> getReplies()
	{
		return replies;
	}
	public void addPost(Post post)
	{
		post.setTopic(this);
		this.replies.add(post);
	}
	public void setReplies(Set<Post> posts)
	{
		this.replies = posts;
	}
	/**
	 * 主题类型(0-普通,1-投票...)
	 */
	public int getType()
	{
		return type;
	}
	public void setType(int type)
	{
		this.type = type;
	}
	/**
	 * 主题状态(0-普通,1-锁定,2-置顶,3-总置顶)//TODO 需要一个自定义status对象,使用32位int存储各种状态(锁定,删除,置顶)
	 */
	public int getStatus()
	{
		return status;
	}
	public void setStatus(int status)
	{
		this.status = status;
	}
	public User getAuthor()
	{
		return author;
	}
	public void setAuthor(User author)
	{
		this.author = author;
	}
	public Board getBoard()
	{
		return board;
	}
	public void setBoard(Board board)
	{
		this.board = board;
	}
	public String getContent()
	{
		return content;
	}
	public void setContent(String content)
	{
		this.content = content;
	}
	public Integer getId()
	{
		return id;
	}
	public void setId(Integer id)
	{
		this.id = id;
	}
	public Timestamp getPublishTime()
	{
		return publishTime;
	}
	public void setPublishTime(Timestamp publishTime)
	{
		this.publishTime = publishTime;
	}
	public int getReplyCount()
	{
		return replyCount;
	}
	public void setReplyCount(int replies)
	{
		this.replyCount = replies;
	}
	public String getSubtitle()
	{
		return subtitle;
	}
	public void setSubtitle(String subtitle)
	{
		this.subtitle = subtitle;
	}
	public String getTitle()
	{
		return title;
	}
	public void setTitle(String title)
	{
		this.title = title;
	}
	public Timestamp getUpdateTime()
	{
		return updateTime;
	}
	public void setUpdateTime(Timestamp updateTime)
	{
		this.updateTime = updateTime;
	}
	public String getUpdateUser()
	{
		return updateUser;
	}
	public void setUpdateUser(String updateUser)
	{
		this.updateUser = updateUser;
	}
	public int getViewCount()
	{
		return viewCount;
	}
	public void setViewCount(int views)
	{
		this.viewCount = views;
	}

	@Override
	public String toString()
	{
		return new ToStringBuilder(this).append("id", id).append("title", title).append("author", author).append("publishTime", publishTime).toString();
	}
}
